package com.syys.privacy.controller;


import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.syys.common.annotation.Log;
import com.syys.common.enums.BusinessType;
import com.syys.privacy.domain.QaPersonalInfoCommission;
import com.syys.privacy.service.IQaPersonalInfoCommissionService;
import com.syys.common.core.controller.BaseController;
import com.syys.common.core.domain.AjaxResult;
import com.syys.common.utils.poi.ExcelUtil;
import com.syys.common.core.page.TableDataInfo;

/**
 * 收集个人信息方式Controller
 *
 * @author ys
 * @date 2021-07-25
 */
@Controller
@RequestMapping("/privacy/commission")
public class QaPersonalInfoCommissionController extends BaseController {
    private String prefix = "privacy/commission";

    @Autowired
    private IQaPersonalInfoCommissionService qaPersonalInfoCommissionService;

    @GetMapping()
    public String privacy() {
        return prefix + "/privacy";
    }

    /**
     * 查询收集个人信息方式列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QaPersonalInfoCommission qaPersonalInfoCommission) {
        startPage();
        List<QaPersonalInfoCommission> list = qaPersonalInfoCommissionService.selectQaPersonalInfoCommissionList(qaPersonalInfoCommission);
        return getDataTable(list);
    }

    /**
     * 导出收集个人信息方式列表
     */
    @Log(title = "收集个人信息方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QaPersonalInfoCommission qaPersonalInfoCommission) {
        List<QaPersonalInfoCommission> list = qaPersonalInfoCommissionService.selectQaPersonalInfoCommissionList(qaPersonalInfoCommission);
        ExcelUtil<QaPersonalInfoCommission> util = new ExcelUtil<QaPersonalInfoCommission>(QaPersonalInfoCommission.class);
        return util.exportExcel(list, "收集个人信息方式数据");
    }

    /**
     * 新增收集个人信息方式
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存收集个人信息方式
     */
    @Log(title = "收集个人信息方式", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QaPersonalInfoCommission qaPersonalInfoCommission) {
        return AjaxResult.success(qaPersonalInfoCommissionService.insertQaPersonalInfoCommission(qaPersonalInfoCommission));
    }

    /**
     * 修改收集个人信息方式
     */
    @GetMapping("/edit/{commissionId}")
    public String edit(@PathVariable("commissionId") Long commissionId, ModelMap mmap) {
        QaPersonalInfoCommission qaPersonalInfoCommission = qaPersonalInfoCommissionService.selectQaPersonalInfoCommissionById(commissionId);
        mmap.put("qaPersonalInfoCommission", qaPersonalInfoCommission);
        return prefix + "/edit";
    }

    /**
     * 修改保存收集个人信息方式
     */
    @Log(title = "收集个人信息方式", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QaPersonalInfoCommission qaPersonalInfoCommission) {
        return toAjax(qaPersonalInfoCommissionService.updateQaPersonalInfoCommission(qaPersonalInfoCommission));
    }

    /**
     * 删除收集个人信息方式
     */
    @Log(title = "收集个人信息方式", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(qaPersonalInfoCommissionService.deleteQaPersonalInfoCommissionByIds(ids));
    }
}